from django.db import models

# Create your models here.

class TaxRate(models.Model):
    name = models.CharField(max_length=120)
    percentage = models.DecimalField(max_digits=5, decimal_places=3)
    
class Biller(models.Model):
    name = models.CharField(max_length=120)
    street_address = models.TextField()
    city = models.CharField(max_length=80)
    state = models.CharField(max_length=30)
    post_code = models.CharField(max_length=12)
    country = models.CharField(max_length=30)
    phone = models.CharField(max_length=30)
    mobile_phone = models.CharField(max_length=30)
    fax = models.CharField(max_length=30)
    email = models.CharField(max_length=30)
    logo = models.ImageField(upload_to='uploaded_images', blank=True, null=True)
    footer = models.TextField(blank=True, null=True)
    notes = models.TextField(blank=True, null=True)
    
class Customer(models.Model):
    name = models.CharField(max_length=120)
    street_address = models.TextField()
    city = models.CharField(max_length=80)
    state = models.CharField(max_length=30)
    post_code = models.CharField(max_length=12)
    country = models.CharField(max_length=30)
    phone = models.CharField(max_length=30, blank=True, null=True)
    mobile_phone = models.CharField(max_length=30, blank=True, null=True)
    fax = models.CharField(max_length=30, blank=True, null=True)
    email = models.CharField(max_length=30, blank=True, null=True)
    notes = models.TextField(blank=True, null=True)
    
class Product(models.Model):
    description = models.CharField(max_length=120)
    unit_price = models.DecimalField(max_digits=15, decimal_places=2)
    minimum_price = models.DecimalField(max_digits=15, decimal_places=2)
    
class InvoiceItem(models.Model):
    invoice = models.ForeignKey(Invoice)
    product = models.ForeignKey(Product)
    quantity = models.IntegerField()
    price = models.DecimalField(max_digits=15, decimal_places=2)
    description = models.TextField()
    gross_total = models.DecimalField(max_digits=15, decimal_places=2)
    
class Invoice(models.Model):
    biller = models.ForeignKey(Biller)
    customer = models.ForeignKey(Customer)
    tax = models.ForeignKey(TaxRate)
    date = models.DateTimeField(auto_now=True)
    postage = models.DecimalField(max_digits=15, decimal_place=2)
    
class Payment(models.Model):
    pass
    
class PaymentType(models.Model):
    pass